/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.helwen.restaurantbooking.datalayer.dao.daoimpl;

import com.helwen.restaurantbooking.datalayer.dao.AbstractDao;
import com.helwen.restaurantbooking.datalayer.dao.ITableDao;
import com.helwen.restaurantbooking.datalayer.entities.TblTable;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Nghiata
 */
@Repository("tableDao")
public class TableDaoImpl extends AbstractDao implements ITableDao {

    public List<TblTable> getAllTable() {
        return getHibernateTemplate().loadAll(TblTable.class);
    }

    public TblTable getBookingByCriteria(Criterion... createrion) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public TblTable getTableByNumber(Integer number) {
        return getHibernateTemplate().get(TblTable.class, number);
    }

    public void saveOrUpdate(TblTable tblTable) {
        getHibernateTemplate().saveOrUpdate(tblTable);
    }

    public void resetAll() {
        getHibernateTemplate().bulkUpdate("update TblTable t set t.status=0");
    }

    public List<TblTable> getTableByArea(boolean isNonSmokingArea) {
        if (isNonSmokingArea) {
            return getHibernateTemplate().find("from TblTable t where t<=5");

        } else {
            return getHibernateTemplate().find("from TblTable t where t>5");
        }
    }
}
